extern crate actix_web;
extern crate log;
extern crate simple_logger;

use actix_web::{server, App};

mod config;
mod route;
mod controller;

fn main() {
    simple_logger::init_with_level(get_debug_level()).unwrap();

    let cfg = config::get_global_config();
    server::new(make_apps)
        .bind(cfg.web.address.clone())
        .unwrap()
        .run();
}

fn make_apps() -> Vec<App> {
    vec![
        route::static_route(route::business_route(App::new())),
    ]
}

fn get_debug_level() -> log::Level {
    if cfg!(debug_assertions) {
        log::Level::Debug
    } else {
        log::Level::Info
    }
}
